{% extends 'dashboard/base.html' %}

{% block body %}

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <br>
                        <div class="d-md-flex align-items-center">
                            <h5 class="card-title">Cookies Sessions List</h5>
                        </div>
                        <br>
                        <div class="row">
                            <div class="table-responsive">
                                <table id="excluded_url" class="table table-bordered data-table">
                                    <thead>
                                    <tr>
                                        <th><p><label><input type="checkbox" id="checkAll"/></label></p></th>
                                        <th>URL</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody>{% for data in all_excluded_url %}
                                    <tr data-target="#">
                                        <td>
                                            <form>
                                                <label><input type="checkbox" value="{{data.exclude_url}}"
                                                              name="del_scan_id"
                                                              onClick="reload">

                                                </label>
                                            </form>
                                        </td>
                                        <td>{{ data.exclude_url }}
                                        </td>
                                        <td>
                                            <form action="{% url 'webscanners:excluded_url_list' %}" method="post"
                                                  class="forms-sample">

                                                {% csrf_token %}
                                                <input type="hidden" name="exclude_url" value="{{ data.exclude_url }}"/>
                                                <button class="btn btn-danger btn-sm"><i class="fas fa-times"></i>
                                                </button>
                                            </form>
                                        </td>
                                    </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">

    $("#checkAll").change(function () {
        $("input:checkbox").prop('checked', $(this).prop("checked"));
    });
    $(document).ready(function() {
        $("button").click(function(){
            var scan_id = ['a7af5b68-b661-45ad-90fd-ffa27526cdce'];
            $.each($("input[name='del_scan_id']:checked"), function(){
                scan_id.push($(this).val());
            });

            var json_scanid = scan_id.join(", ");
            $.ajax({
                type:'POST',
                <!--contentType: 'application/json; charset=utf-8',-->
                url:'{% url 'webscanners:excluded_url_list' %}',
                data:{
                   exclude_url: json_scanid,
                   csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val()
                },
                sucess:function(){

                }
            });
            setTimeout(function(){location.reload();},1000);
        });

    });



</script>
{% endblock %}